package biz.obake.team.touchprotector.ui;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import androidx.preference.Preference;
import biz.obake.team.touchprotector.R;
import biz.obake.team.touchprotector.c;
import biz.obake.team.touchprotector.e.a;
import biz.obake.team.touchprotector.fingerprint.FingerprintActivity;
import biz.obake.team.touchprotector.g.b;
import biz.obake.team.touchprotector.g.e;

public class Tab_Donation extends a {
    private void checkPinValidity() {
        if (!a.d()) {
            e.a(R.string.toast_pin_invalid);
            a.a();
            reloadSelf();
        }
    }

    /* access modifiers changed from: private */
    public void onSoundClick(int i) {
        int i2;
        String str;
        if (i == 0) {
            str = biz.obake.team.touchprotector.g.a.l("lock_sound");
            i2 = R.string.feature_locksound_picker_title_lock_sound;
        } else if (i == 1) {
            str = biz.obake.team.touchprotector.g.a.l("unlock_sound");
            i2 = R.string.feature_locksound_picker_title_unlock_sound;
        } else {
            throw new b("{8FF74EA2-76C7-472B-8740-CE41356C11E2}" + i);
        }
        String w = c.w(i2);
        Intent intent = new Intent("android.intent.action.RINGTONE_PICKER");
        intent.putExtra("android.intent.extra.ringtone.TITLE", w);
        intent.putExtra("android.intent.extra.ringtone.TYPE", 2);
        intent.putExtra("android.intent.extra.ringtone.SHOW_DEFAULT", true);
        intent.putExtra("android.intent.extra.ringtone.SHOW_SILENT", true);
        intent.putExtra("android.intent.extra.ringtone.DEFAULT_URI", Settings.System.DEFAULT_NOTIFICATION_URI);
        if (str.length() > 0) {
            intent.putExtra("android.intent.extra.ringtone.EXISTING_URI", Uri.parse(str));
        }
        startActivityForResult(intent, i);
    }

    private void updateDonationPref(String str) {
        Preference H0 = getPreferenceScreen().H0("donation");
        if (H0 != null) {
            char c2 = 65535;
            int hashCode = str.hashCode();
            if (hashCode != -1696429662) {
                if (hashCode != -791831627) {
                    if (hashCode == 67232232 && str.equals("Error")) {
                        c2 = 2;
                    }
                } else if (str.equals("Donated")) {
                    c2 = 0;
                }
            } else if (str.equals("NotDonated")) {
                c2 = 1;
            }
            if (c2 == 0) {
                H0.u0(R.string.pref_donate_summary_donated);
            } else if (c2 != 1) {
                if (c2 == 2) {
                    H0.u0(R.string.pref_donate_summary_unavailable);
                    H0.l0(false);
                    return;
                }
                return;
            }
            H0.l0(true);
        }
    }

    private void updateFingerprintPref(String str) {
        int i;
        Preference H0 = getPreferenceScreen().H0("require_fingerprint");
        if (!FingerprintActivity.d()) {
            i = R.string.pref_require_fingerprint_hardware_unavailable;
        } else if (!FingerprintActivity.c()) {
            i = R.string.pref_require_fingerprint_fingerprint_unavailable;
        } else if (!a.c()) {
            i = R.string.pref_require_fingerprint_pin_unavailable;
        } else {
            H0.u0(R.string.pref_require_fingerprint_summary);
            if ("Donated" == str) {
                H0.l0(true);
                return;
            }
            H0.l0(false);
        }
        H0.u0(i);
        H0.l0(false);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:4:0x001e, code lost:
        r1 = biz.obake.team.android.a.a();
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void updateLockSoundPref(java.lang.String r3, java.lang.String r4) {
        /*
            r2 = this;
            r2.updatePrefSimple(r3, r4)
            androidx.preference.PreferenceScreen r3 = r2.getPreferenceScreen()
            androidx.preference.Preference r3 = r3.H0(r4)
            r0 = 2131623991(0x7f0e0037, float:1.887515E38)
            java.lang.String r0 = biz.obake.team.touchprotector.c.w(r0)
            java.lang.String r4 = biz.obake.team.touchprotector.g.a.l(r4)
            if (r4 == 0) goto L_0x0030
            int r1 = r4.length()
            if (r1 <= 0) goto L_0x0030
            biz.obake.team.android.a r1 = biz.obake.team.android.a.a()
            android.net.Uri r4 = android.net.Uri.parse(r4)
            android.media.Ringtone r4 = android.media.RingtoneManager.getRingtone(r1, r4)
            if (r4 == 0) goto L_0x0030
            java.lang.String r0 = r4.getTitle(r1)
        L_0x0030:
            r3.v0(r0)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: biz.obake.team.touchprotector.ui.Tab_Donation.updateLockSoundPref(java.lang.String, java.lang.String):void");
    }

    private void updatePrefSimple(String str, String str2) {
        Preference H0 = getPreferenceScreen().H0(str2);
        if (((str.hashCode() == -791831627 && str.equals("Donated")) ? (char) 0 : 65535) != 0) {
            H0.l0(false);
        } else {
            H0.l0(true);
        }
    }

    private void updatePrefs() {
        String c2 = biz.obake.team.touchprotector.g.c.c("Donation.Status");
        updateDonationPref(c2);
        updatePrefSimple(c2, "pin");
        updateRequirePinPref(c2);
        updateFingerprintPref(c2);
        updateLockSoundPref(c2, "lock_sound");
        updateLockSoundPref(c2, "unlock_sound");
        updatePrefSimple(c2, "backlight_gesture");
        updatePrefSimple(c2, "backlight_gesture_panel");
        prefUpdateListSummary("backlight_gesture_panel");
        updatePrefSimple(c2, "unlockable_lock_screen_now");
        updatePrefSimple(c2, "tasker");
    }

    private void updateRequirePinPref(String str) {
        Preference H0 = getPreferenceScreen().H0("require_pin");
        if (!a.c()) {
            H0.u0(R.string.pref_require_pin_pin_unavailable);
        } else {
            H0.u0(R.string.pref_require_pin_summary);
            if ("Donated" == str) {
                H0.l0(true);
                return;
            }
        }
        H0.l0(false);
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        String str;
        if (i == 0) {
            str = "lock_sound";
        } else if (i == 1) {
            str = "unlock_sound";
        } else {
            throw new b("{7DC98A36-C329-42B1-A0D8-714C1B9A5B7A}" + i);
        }
        if (i2 == -1 && intent != null) {
            Uri uri = (Uri) intent.getParcelableExtra("android.intent.extra.ringtone.PICKED_URI");
            biz.obake.team.touchprotector.g.a.r(str, uri == null ? "" : uri.toString());
        }
    }

    public void onCreatePreferences(Bundle bundle, String str) {
        setPreferencesFromResource(R.xml.ui_tab_donation, str);
        getPreferenceScreen().H0("lock_sound").s0(new Preference.e() {
            public boolean onPreferenceClick(Preference preference) {
                Tab_Donation.this.onSoundClick(0);
                return true;
            }
        });
        getPreferenceScreen().H0("unlock_sound").s0(new Preference.e() {
            public boolean onPreferenceClick(Preference preference) {
                Tab_Donation.this.onSoundClick(1);
                return true;
            }
        });
        updatePrefs();
    }

    /* access modifiers changed from: protected */
    /* JADX WARNING: Can't fix incorrect switch cases order */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void onPrefChanged(android.content.SharedPreferences r9, java.lang.String r10) {
        /*
            r8 = this;
            int r9 = r10.hashCode()
            r0 = 5
            r1 = 4
            r2 = 3
            r3 = 2
            r4 = 1
            r5 = 0
            java.lang.String r6 = "require_pin"
            java.lang.String r7 = "require_fingerprint"
            switch(r9) {
                case -938375084: goto L_0x0040;
                case -395290358: goto L_0x0038;
                case 110997: goto L_0x002e;
                case 362981307: goto L_0x0026;
                case 874988510: goto L_0x001c;
                case 1234969851: goto L_0x0012;
                default: goto L_0x0011;
            }
        L_0x0011:
            goto L_0x004a
        L_0x0012:
            java.lang.String r9 = "lock_sound"
            boolean r9 = r10.equals(r9)
            if (r9 == 0) goto L_0x004a
            r9 = 4
            goto L_0x004b
        L_0x001c:
            java.lang.String r9 = "backlight_gesture_panel"
            boolean r9 = r10.equals(r9)
            if (r9 == 0) goto L_0x004a
            r9 = 3
            goto L_0x004b
        L_0x0026:
            boolean r9 = r10.equals(r6)
            if (r9 == 0) goto L_0x004a
            r9 = 1
            goto L_0x004b
        L_0x002e:
            java.lang.String r9 = "pin"
            boolean r9 = r10.equals(r9)
            if (r9 == 0) goto L_0x004a
            r9 = 0
            goto L_0x004b
        L_0x0038:
            boolean r9 = r10.equals(r7)
            if (r9 == 0) goto L_0x004a
            r9 = 2
            goto L_0x004b
        L_0x0040:
            java.lang.String r9 = "unlock_sound"
            boolean r9 = r10.equals(r9)
            if (r9 == 0) goto L_0x004a
            r9 = 5
            goto L_0x004b
        L_0x004a:
            r9 = -1
        L_0x004b:
            if (r9 == 0) goto L_0x0078
            if (r9 == r4) goto L_0x0068
            if (r9 == r3) goto L_0x0058
            if (r9 == r2) goto L_0x007b
            if (r9 == r1) goto L_0x007b
            if (r9 == r0) goto L_0x007b
            goto L_0x007e
        L_0x0058:
            boolean r9 = biz.obake.team.touchprotector.g.a.g(r6)
            if (r9 == 0) goto L_0x007b
            boolean r9 = biz.obake.team.touchprotector.g.a.g(r7)
            if (r9 == 0) goto L_0x007b
            r8.prefSwitch(r6, r5)
            goto L_0x007b
        L_0x0068:
            boolean r9 = biz.obake.team.touchprotector.g.a.g(r6)
            if (r9 == 0) goto L_0x007b
            boolean r9 = biz.obake.team.touchprotector.g.a.g(r7)
            if (r9 == 0) goto L_0x007b
            r8.prefSwitch(r7, r5)
            goto L_0x007b
        L_0x0078:
            r8.checkPinValidity()
        L_0x007b:
            r8.updatePrefs()
        L_0x007e:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: biz.obake.team.touchprotector.ui.Tab_Donation.onPrefChanged(android.content.SharedPreferences, java.lang.String):void");
    }

    /* access modifiers changed from: protected */
    public void onRamPrefChanged(String str) {
        if (((str.hashCode() == -540128818 && str.equals("Donation.Status")) ? (char) 0 : 65535) == 0) {
            updatePrefs();
        }
    }

    public void onResume() {
        super.onResume();
        updatePrefs();
    }
}
